package qz_rpt

class WipInventoryController {

    def dynamicQueryService
    def wipInventory() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def wipInventorySum=[]
        def tableHeadList=[]
        def wipInventory=[]
        def list=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        params.SYS_QUERY_NAME = 'wipInventorySumQty'
        def wipInventorySumQty = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'wipInventoryPartDirection'
        def wipInventoryPartDirection = dynamicQueryService.queryForList(params)

        params.SYS_QUERY_NAME = 'wipInventoryTotalGroup'
        def wipInventoryTotalGroup = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'wipInventoryDetailCate'
        def wipInventoryDetailCate = dynamicQueryService.queryForList(params)
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'wipInventory'
            wipInventory = dynamicQueryService.queryForList(params)
            if (wipInventory.size() > 0) {
                tableHeadList = wipInventory[0].keySet()
            }
            params.SYS_QUERY_NAME = 'wipInventoryCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
            //list=TranposUtils.colToRow('STEP_NAME','STEP_QTY',partFinList)

//            params.SYS_QUERY_NAME = 'orderStatusAnalysisSum'
//            orderStatusAnalysisSum = dynamicQueryService.queryForList(params)

        }
        [pageSize     : pageSize, totalCount: totalCount, pageSizeList: pageSizeList,pageCurrent:pageCurrent,wipInventoryTotalGroup:wipInventoryTotalGroup,
         wipInventorySum:wipInventorySum,tableHeadList:tableHeadList,wipInventory:wipInventory,startno:params.startno?:'',endno:params.endno?:'',wipInventoryDetailCate:wipInventoryDetailCate,
         startTime:params.startTime,endTime:params.endTime,partName:params.partName,stepName:params.stepName,wipInventoryPartDirection:wipInventoryPartDirection,
        totalGroup:params.totalGroup,detailCate:params.detailCate,partDirection:params.partDirection,group3:params.group3,wipInventorySumQty:wipInventorySumQty]
    }
}
